package com.woniuxy.yoga.config;

import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.ApiSelectorBuilder;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    public Docket creatRequestApi(){
        Docket docket = new Docket(DocumentationType.SWAGGER_2);
        ApiInfo apiInfo = apiInfo();
        ApiSelectorBuilder apiSelectorBuilder = docket.apiInfo(apiInfo).select();
        Docket newDocket = apiSelectorBuilder.apis(RequestHandlerSelectors.basePackage("com.woniuxy.yoga.controller")).build();
        return newDocket;

    }

    private ApiInfo apiInfo() {
        ApiInfo apiInfo=new ApiInfoBuilder()
                .title("瑜伽项目")//标题
                .description("瑜伽项目测试接口")//描述
                .contact(new Contact("axq","http://www.axq.org","1830387851@qq.com"))//联系人
                .version("v1.0")//版本
                .license("蜗牛学院") //版权
                .build();
        return apiInfo;
    }

}
